<template>
  <a-form
    :model="formState"
    ref="formDataRef"
    name="basic"
    :label-col="{ style: 'width:80px' }"
    :wrapper-col="{ style: 'calc(100% - 80px)' }"
    autocomplete="off"
    @finish="onFinish"
    @finishFailed="onFinishFailed"
  >
    <a-form-item label="标识" name="lookupItemCode" :rules="[{ required: true, message: '请填写件数!' }]">
      <a-select mode="multiple" :max-tag-count="1" v-model:value="formState.lookupItemCode" placeholder="请选择">
        <a-select-option v-for="(item, index) in dataDict['LOGOTYPE']" :key="index" :value="item.code">{{ item.name }}</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="操作类型" name="markType" :rules="[{ required: true, message: '请选择操作类型!' }]">
      <a-radio-group v-model:value="formState.markType" name="radioGroup">
        <a-radio :value="1">添加</a-radio>
        <a-radio :value="2">移除</a-radio>
      </a-radio-group>
    </a-form-item>
    <a-form-item :wrapper-col="{ offset: 8, span: 16 }" class="submit-btn-form-item">
      <a-button :loading="loading" type="primary" html-type="submit">确定</a-button>
      <a-button @click="resetHandle">取消</a-button>
    </a-form-item>
  </a-form>
</template>

<script lang="ts" setup>
import { toRefs, watch } from "vue";
import InitHook from "./composables/initHook";
import OperationHook from "./composables/operationHook";
import CommonHook from "@/hook/commonHook";
const props = withDefaults(
  defineProps<{
    visible: boolean;
    passData: CustomerServiceWaybill.ListRows;
  }>(),
  {}
);
const emit = defineEmits<{
  (e: "update:visible", blo: boolean): void;
  (e: "submit"): void;
}>();
const { visible, passData } = toRefs(props);
const { dataDict } = CommonHook();
const { formDataRef, formState, loading } = InitHook();
const { onFinish, onFinishFailed, resetFields, resetHandle } = OperationHook({
  formDataRef,
  formState,
  passData,
  emit,
  loading,
  dataDict
});
watch(
  () => visible.value,
  (v: boolean) => {
    if (!v) {
      resetFields();
      formDataRef.value.clearValidate();
    }
  }
);
</script>
<style lang="stylus" scoped>
:deep(.ant-picker){
    width: 100%;
}
</style>
